package com.neusoft.controller;

import com.neusoft.entity.Disease;
import com.neusoft.service.DiseaseService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/disease")
@CrossOrigin
public class DiseaseController {
    @Autowired
    private DiseaseService diseaseService;

    /**
     * 查询所有疾病
     *
     * @return 疾病列表
     */
    @RequestMapping("/queryAllDisease")
    public Result queryAllDisease() {
        return diseaseService.queryAllDisease();
    }

    /**
     * 分页查询疾病列表
     *
     * @param currentPage 当前页码
     * @param pageSize    每页条数
     * @return 疾病列表
     */
    @RequestMapping("/queryDiseaseByPage/{currentPage}/{pageSize}")
    public Result queryDiseaseByPage(@PathVariable int currentPage, @PathVariable int pageSize) {
        return diseaseService.queryDiseaseByPage(currentPage, pageSize);
    }

    /**
     * 查询疾病数量
     *
     * @return 疾病数量
     */
    @RequestMapping("/queryDiseaseCount")
    public Result queryDiseaseCount() {
        return diseaseService.queryDiseaseCount();
    }

    /**
     * 根据条件分页查询疾病列表
     *
     * @param disease     条件
     * @param currentPage 当前页码
     * @param pageSize    每页条数
     * @return 疾病列表
     */
    @RequestMapping("/queryDiseaseByCondition/{currentPage}/{pageSize}")
    public Result queryDiseaseByCondition(@RequestBody Disease disease,
                                          @PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return diseaseService.queryDiseaseByCondition(disease, currentPage, pageSize);
    }
}
